<meta charset="UTF-8" />
<title>去重</title>

<textarea id="ipt" cols="80" rows="10"></textarea>
<br><br>
<button id="btn">提交</button>
<br><br>
<table border cellspacing="0" id="res">

</table>

<script>
btn.onclick = function() {
    const rows = ipt.value.split("\n").map(line => line.split("\t"));
    const results = Array.from(rows.flat().flat()).filter(item => item);
    const map = new Map();
    for (const item of results) {
        if (!map.has(item)) {
            map.set(item, 0);
        }
        map.set(item, map.get(item) + 1);
    }
    res.innerHTML = [
        ...Array.from(map.entries()).map(([item, count]) => {
            return `<tr><td>${item}</td><td>${count}</td></tr>`;
        }),
        `<tr><td>${"总数"}</td><td>${results.length}</td></tr>`
    ].join("");
}

</script>